package com.topi.sharing.json;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

public class DateTimeSerializer  extends JsonSerializer<Date> {

	public static final String DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";

	@Override
	public void serialize(Date value
						, JsonGenerator gen
						, SerializerProvider provider ) throws IOException {
		gen.writeString((new SimpleDateFormat(DATE_PATTERN).format(value)));
	}
}
